<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <!--引入富文本编辑器css-->
    <link href="https://cdn.staticfile.org/wangeditor5/5.1.23/css/style.min.css" rel="stylesheet">

    <style>
        .center{
            width: 1200px;
            margin: 0 auto;
        }
        #footer_center p{
            margin: 0;
        }
        #footer_center h3{
            color: white;
        }
        body{
            background-color: rgb(241,242,243);
        }
        .el-header{
            background-color: white;
        }
    </style>
</head>
<body>
<div id="app" >
    <el-container>
        <my-header></my-header>

        <el-main class="center">
            <el-row gutter="20">
                <el-col span="20">
                    <el-card>
                        <!--标签页卡开始-->
                        <el-tabs type="card">
                            <el-tab-pane label="余额充值"></el-tab-pane>
                        </el-tabs>
                        <!--标签页卡结束-->
                        <el-form label-width="200px">
                            <img v-if="showQrcode" style="margin-left: 300px;width: 300px;height: 400px"
                                 src="http://rvg6mjj7z.hn-bkt.clouddn.com/img/mm_facetoface_collect_qrcode_1687761290169.png">
                            <el-form-item v-if="!showQrcode" label="充值金额">
                                <el-input placeholder="请输入金额" v-model="balance" style="width: 200px"></el-input>
                            </el-form-item>
                            <el-form-item v-if="!showQrcode">
                                <el-button type="primary" @click="showQrcode = true">充值</el-button>
                            </el-form-item>
                            <el-form-item v-if="showQrcode">
                                <el-button type="warning" style="margin-left: 130px;background-color: #cccccc" @click="showQrcode = false">取消</el-button>
                                <el-button type="succeed" style="margin-left: 100px;background-color: green;color: white" @click="post">已付款</el-button>
                            </el-form-item>
                            <div v-if="showQrcode" style="text-align: center">为确保及时到账，请保证付款金额和充值金额相同</div>
                        </el-form>
                    </el-card>
                </el-col>
            </el-row>
        </el-main>

        <el-footer >

        </el-footer>
    </el-container>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<!--引入富文本编辑器js-->
<script src="https://cdn.staticfile.org/wangeditor5/5.1.23/index.min.js"></script>
<!--引入Axios-->
<script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
<!--引入自己的js文件-->
<script src="js/my-header.js"></script>
<script src="js/my-footer.js"></script>

<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                balance: '',
                showQrcode: false,
                order:{id:"",amount:"",userid:"",completed:""}
            }
        },
        methods: {
            post() {
                let user_id = localStorage.user?JSON.parse(localStorage.user).userid:null;
                v.order.id = user_id+Number(new Date())%1000000;
                v.order.amount = v.balance;
                v.order.userid = user_id;
                v.order.completed = 0;
                axios.post("/v1/recharge/insert",v.order)
                    .then(function (response) {
                    })
                alert("等待管理员审核！");
                location.href='/';
            }
        },
        created:function () {
        }
    })
</script>
</html>